package day03;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.List;

public class ProxyListHandler<E> implements InvocationHandler {
    private List<E> target;
    public ProxyListHandler(List<E> list){
        target = list;
    }
    @Override
    public Object invoke(
            Object proxy,
            Method method,
            Object[] args) throws Throwable {
        System.out.println("ProxyListHandler.invoke");
        synchronized (target){
            return method.invoke(target, args);
        }
    }
}
